<%@ page language="java"
         contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"
         import="com.shxt.hotel.background.Consume"
         import="java.util.Map"
         import="java.util.List"
         import="com.shxt.hotel.background.Staff"
%>
<%
    Staff staff = new Staff();
    
    if(session.getAttribute("staff_id") == null){
        response.sendRedirect("./login.jsp");
    }else{
        // get current Staff
        request.setCharacterEncoding("UTF-8");
        int staff_id = (int)session.getAttribute("staff_id");

        // room object
        Consume consume = new Consume();
%>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <base href="javascript:void(0)" target="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <link rel="shortcut icon" href="../Public/img/favicon.html">

    <title>Consume Type</title>

    <!-- Bootstrap core CSS -->
    <link href="../Public/css/bootstrap.min.css" rel="stylesheet">
    <link href="../Public/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="../Public/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="../Public/css/style.css" rel="stylesheet">
    <link href="../Public/css/style-responsive.css" rel="stylesheet" />

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="../Public/js/html5shiv.js"></script>
      <script src="../Public/js/respond.min.js"></script>
    <![endif]-->
</head>

<body>

    <section id="container" class="">
        <!--header start-->
        <jsp:include page="./Public/header.jsp" flush="true"/>
        <!--header end-->
        <!--sidebar start-->
        <jsp:include page="./Public/sidebar.jsp" flush="true"/>
        <!--sidebar end-->
        <!--main content start-->
        <section id="main-content">
            <section class="wrapper">
                <!-- page start-->
                <div class="row">
                    <div class="col-lg-9">
                        <section class="panel panel-primary">
                            <header class="panel-heading">
                                Consume Type
                            </header>
                            <table class="table table-striped border-top" id="sample_1">
                                <thead>
                                    <tr>
                                        <th style="width:8px;"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes" /></th>
                                        <th>Category ID</th>
                                        <th class="hidden-phone">Category Name</th>
                                        <th class="hidden-phone">Operation</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <%
                                        // get all Category
                                        List<Map<String, Object>> categoryList = consume.getCategories();
                                        
                                        for(Map<String, Object> cate : categoryList){
                                    %>
                                           <tr class="odd gradeX">
                                               <td><input type="checkbox" class="checkboxes" value="1" /></td>
                                               <td><%=cate.get("id") %></td>
                                               <td class="hidden-phone"><%=cate.get("title") %></td>
                                               <td class="hidden-phone">
                                                    <button class="btn btn-info btn-xs" type="button"><i class="icon-edit"></i> Edit</button>
                                                    <button class="btn btn-danger btn-xs" type="button"><i class="icon-remove"></i> Delete</button>
                                               </td>
                                           </tr> 
                                    <%
                                        }
                                    %>
                                </tbody>
                            </table>
                        </section>
                    </div>
                    
                    <div class="col-lg-3">
                        <section class="panel panel-primary">
                            <header class="panel-heading">Category Operation</header>
                            <div class="panel-body">
                            
                                <a href="#category-model" data-toggle="modal" class="btn btn-info">
                                    New Category
                                </a>

                                <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="category-model" class="modal fade">
                                    <div class="modal-dialog">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                                                <h4 class="modal-title">New Category</h4>
                                            </div>
                                            <div class="modal-body">

                                                <form role="form" action="./background/consume_category_add_do.jsp" method="post">
                                                    <%
                                                        int cateSize = categoryList.size();
                                                    %>
                                                    <div class="form-group">
                                                        <label for="Category title">Category ID</label>
                                                        <input name="id" type="text" class="form-control" id="Category title" value="<%=cateSize %>" autocomplete="off">
                                                    </div>
                                                    <div class="form-group">
                                                        <label for="Category title">Category Name</label>
                                                        <input name="title" type="text" class="form-control" id="Category title" placeholder="Enter Name" autocomplete="off">
                                                    </div>
                                                    <br/>
                                                    <button type="submit" class="btn btn-info">Submit</button>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                
                            </div>
                        </section>
                    </div>
                </div>
                <!-- page end-->
            </section>
        </section>
        <!--main content end-->
    </section>

    <!-- js placed at the end of the document so the pages load faster -->
    <script src="../Public/js/jquery.js"></script>
    <script src="../Public/js/bootstrap.min.js"></script>
    <script src="../Public/js/jquery.scrollTo.min.js"></script>
    <script src="../Public/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Public/assets/data-tables/jquery.dataTables.js"></script>
    <script type="text/javascript" src="../Public/assets/data-tables/DT_bootstrap.js"></script>


    <!--common script for all pages-->
    <script src="../Public/js/common-scripts.js"></script>

    <!--script for this page only-->
    <script src="../Public/js/dynamic-table.js"></script>
    
    <!--scripted by myself-->
    <script>
        $(document).ready(function(){
            $("#Hotel_Consume").addClass("active");
            $("#consume_category").addClass("active");
        });
    </script>


</body>

</html>
<%
        consume.close();
    }
%>